Skip to main content

mockseries.transition.lambda_transition

LambdaTransition#

class LambdaTransition(Transition)

Transition from any transition function.

The transition from the base value to the switch value takes a given time: a transition window. On this given time, the change follows a given transition function. A transition function is defined on 0-1 and represent the change behaviour (eg linear, exponential, etc...).

If not provided, the stop window is considered 0, and the change is direct. If a stop window is provided without stop function, the stop function is defaulted to the symmetric of the transition function.

Arguments:

  • transition_window - Time taken to transition.
  • transition_function - Transition function defined on 0-1, with t(0)=0 and t(1)=1.
  • stop_window - Time taken to stop, ie transition to original value.
  • stop_function - Stop transition function defined on 0-1, with s(0)=0 and s(1)=1.

Examples:

from datetime import datetime, timedelta
from mockseries.transition import LambdaTransition
square = lambda x: x * x
linear = lambda x: x
transition = LambdaTransition(
transition_window=timedelta(hours=12),
transition_function=square,
stop_window=timedelta(hours=24),
stop_function=linear,
)

get_mask#

| get_mask(time_points: np.ndarray, start_time: datetime, stop_time: datetime) -> np.ndarray

Returns the transition mask.